package desginmode.single

/**
 * 懒加载，线程安全(Lazy单例)
 */
class ThreadSafeSingle private constructor() {

    fun getName() = "ThreadSafeSingle"

    companion object {
        val instance by lazy(LazyThreadSafetyMode.SYNCHRONIZED) {
            ThreadSafeSingle()
        }
    }
}

fun main(args: Array<String>) {
    print(ThreadSafeSingle.instance.getName())
}